/*
 * @Author: tianchao
 * @Date: 2022-09-26 17:05:19
 * @LastEditTime: 2022-09-26 18:55:18
 * @LastEditors: tianchao
 * @Description:
 * @FilePath: \JsonToJs\WbqjI18n.js
 * TOMATO GAME
 */
const OldI18n = require("./js/zh");
var jsonFile = require("jsonfile");

var fileName = "./minijson/zh.json";
var NewFile = "./newjs/zh.json";
var modifyFile = "./newjs/modify.json";

/**
 * @description: 找到差异字段
 * @return {*}
 */
function findDisparity() {
	jsonFile.readFile(fileName, function (err, jsonData) {
		if (err) throw err;
		// 写入列表
		let writeList = jsonData;
		// 修改列表
		let modifyList = {};
		for (const key in OldI18n) {
			if (!jsonData[key]) {
				writeList[key] = OldI18n[key];
			} else if (OldI18n[key] != jsonData[key]) {
				writeList[key] = OldI18n[key];
				modifyList[key] = OldI18n[key];
			}
		}
		jsonFile.writeFileSync(NewFile, writeList, { flag: "a" });
		jsonFile.writeFileSync(modifyFile, modifyList, { flag: "a" });
	});
}

findDisparity();
